package com.kotlin.base.di

import android.content.Context
import com.kotlin.base.utils.Network
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.Dispatchers
import javax.inject.Singleton
import kotlin.coroutines.CoroutineContext

@Module
@InstallIn(SingletonComponent::class)
class CoreModule {

    /**
     * 单例
     * 由provides提供依赖
     * 提供协程线程
     */
    @Singleton
    @Provides
    fun provideCoroutineContext(): CoroutineContext = Dispatchers.IO


    /**
     * 提供网络连接判断
     * @ApplicationContext 是一种@Qualifier修饰器实现，用于区分Context和ApplicationContext
     */
    @Singleton
    @Provides
    fun provideNetworkConnectivity(@ApplicationContext context: Context) = Network(context)
}